package org.example.collection;

import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
import java.util.Set;

/**
 *  put
 *  get
 *  remove
 *  size
 */
public class MapDemo {
    public static void main(String[] args) {
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("1","abc"); // 线程不安全的
        hashMap.put("1","abc"); // 线程不安全的

        Hashtable<String, String> hashTable = new Hashtable<>();
        hashTable.put("1","abc"); // 线程安全的

        System.out.println(hashMap.get("1"));
        System.out.println(hashMap.containsKey("1"));
        Set<Map.Entry<String, String>> entries = hashMap.entrySet();
        for (Map.Entry<String, String> hh : entries) {
            System.out.println(hh.getKey() + "  " + hh.getValue());
        }


    }
}
